import Mock from 'mockjs'
import type { ApiType } from './types'

// 获取 mock.Random 对象
const Random = Mock.Random;
/*--------------- 折线 ---------------*/
// mock一组数据
const line1 = (): ApiType => {
  const datas: [] = Mock.mock({
    'colors|4': ['@color'],
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}

const line2 = (): ApiType => {
  const datas: [] = Mock.mock({
    'colors|4': ['@color'],
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}

const line3 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
/*--------------- 折线 end ---------------*/

/*--------------- 柱状 ---------------*/
const bar1 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
const bar2 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
const bar3 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
/*--------------- 柱状 end ---------------*/

/*--------------- 饼图 ---------------*/
const pei1 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
const pei2 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
const pei3 = (): ApiType => {
  const datas: [] = Mock.mock({
    list: {
      'todayGrowth|30': ['@integer(1, 100)'],
      'yesterdayGrowth|30': ['@integer(1, 100)'],
    }
  })
  return {
    code: 0,
    data: datas,
    message: '操作成功'
  }
}
/*--------------- 饼图 end ---------------*/

export default [
  {
    url: 'charts/line1',
    method: 'get',
    response: line1
  },
  {
    url: 'charts/line2',
    method: 'get',
    response: line2
  },
  {
    url: 'charts/line3',
    method: 'get',
    response: line3
  },
  {
    url: 'charts/bar1',
    method: 'get',
    response: bar1
  },
  {
    url: 'charts/bar2',
    method: 'get',
    response: bar2
  },
  {
    url: 'charts/bar3',
    method: 'get',
    response: bar3
  },
  {
    url: 'charts/pei1',
    method: 'get',
    response: pei1
  },
  {
    url: 'charts/pei2',
    method: 'get',
    response: pei2
  },
  {
    url: 'charts/pei3',
    method: 'get',
    response: pei3
  },
]